<?php

class Application_Model_DbTable_UserAccountHistory extends Application_Model_DbTable_DomainObject{
    
    protected $_name='uuch_account_history';
    
    public function getMapper() {
        return array('id','type','beforeMoney','afterMoney','comment','dateCreated'
            ,'relaseId','beforeScore','afterScore','accountId','state','source');
    }
       
    /**
     * 查询历史记录
     * @param int $userId 用户ID
     * @param int $type 操作类型
     * @param date $dateStart 开始时间
     * @param date $dateEnd 结速时间
     * @param int $count 每页记录数
     * @param int $offset 从第几条开始
     * @return arrry 返回格式为 array('size'=>?,'list'=>?,'pages'=>?,'index'=>?) 
     * size为查询记录的总条数，list为返回的array型数据，pages是指有多少页，index为当前是哪一页
     */
    public function search($userId,$type,$dateStart,$dateEnd,$count,$offset){
        $condintion = array('accountId'=>$userId,' and dateCreated >='=>$dateStart,' and dateCreated <='=>$dateEnd);
        if($type)
            $condintion['and type =']=$type;
        return $this->queryPage($condintion,'dateCreated',$count,$offset);
    }
}